//
//  GYConfirmOrderAddressTableViewCell.m
//  GoodLuck
//
//  Created by 郭为勇 on 2018/3/27.
//  Copyright © 2018年 yunjiazhineng. All rights reserved.
//

static NSString *confirmOrderAddressCellIdentifier = @"confirmOrderAddressCellIdentifier";

#import "GYConfirmOrderAddressTableViewCell.h"

@interface GYConfirmOrderAddressTableViewCell ()

@property (weak, nonatomic) IBOutlet UIImageView *selectImageview;
@property (weak, nonatomic) IBOutlet UILabel *receiveNameLbale;
@property (weak, nonatomic) IBOutlet UILabel *receivePhoneLable;
@property (weak, nonatomic) IBOutlet UILabel *defaultLable;
@property (weak, nonatomic) IBOutlet UILabel *addressLable;

@end
@implementation GYConfirmOrderAddressTableViewCell

- (void)awakeFromNib {
    [super awakeFromNib];
    // Initialization code
    self.defaultLable.layer.cornerRadius = 2;
    self.defaultLable.layer.masksToBounds = YES;
}

+ (instancetype)cellWithTableView:(UITableView *)tableView {
    GYConfirmOrderAddressTableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:confirmOrderAddressCellIdentifier];
    if (cell == nil) {
        cell = [[[NSBundle mainBundle] loadNibNamed:NSStringFromClass([self class]) owner:nil options:nil] firstObject];
    }
    
    return cell;
}

- (void)setAddressModel:(GYRecriveAddress *)addressModel {
    _addressModel = addressModel;
    
    //赋值
    if (addressModel.isSelectedState) {
        self.selectImageview.hidden = NO;
    }else {
        self.selectImageview.hidden = YES;
    }
    
    self.defaultLable.hidden = addressModel.is_default == 1 ? NO : YES;
    self.receiveNameLbale.text = addressModel.true_name;
    self.receivePhoneLable.text = addressModel.mob_phone;
    self.addressLable.text = [NSString stringWithFormat:@"%@ %@",addressModel.area_info,addressModel.address];
}

- (CGFloat)getHeight:(GYRecriveAddress *)model {
    self.addressModel = model;
    
    [self layoutIfNeeded];
    
    return CGRectGetMaxY(self.addressLable.frame) + 10;
}
@end
